package com.bainuo.doctor.common.util;

import android.content.Context;
import android.widget.Toast;

import com.blankj.utilcode.utils.Utils;

/**
 * Description:
 * Created by MonkeyShen on 2017/3/15.
 * Mail:shenminjie92@sina.com
 */

public class ToastUtils {

    public static Toast toast;
    /**
     * 避免二次显示
     *
     * @param content
     */
    public static void showToast(CharSequence content) {
        if (toast != null)
            toast.cancel();
        toast =  Toast.makeText(Utils.getContext(), content, Toast.LENGTH_SHORT);
        toast.show();
//        if (toast == null) {
//            toast = Toast.makeText(Utils.getContext(),
//                    content,
//                    Toast.LENGTH_SHORT);
//        } else {
//            toast.setText(content);
//        }
//        toast.show();

//        if (toast == null) {
//            toast = new Toast(Utils.getContext());
//            LayoutInflater inflate = (LayoutInflater)
//                    Utils.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//            View view = inflate.inflate(R.layout.toast_common_layout, null);
//            TextView tv = (TextView) view.findViewById(R.id.tv_content);
//            tv.setText(content);
//            toast.setView(view);
//        } else {
//            TextView tv = (TextView) toast.getView().findViewById(R.id.tv_content);
//            tv.setText(content);
//        }
//        toast.setGravity(Gravity.CENTER, 0, 0);
//        toast.show();
    }


}
